#include <iostream>
#include <string>
#include <fstream>
#include <vector>
using namespace std;


int copyReverse(string originFileName, string destFileName){
	vector<string> v;
	fstream file1, file2;
	file1.open(originFileName.c_str(), ios_base::in);
	if (!file1){
		cout << "read input file error!";
	}
	file2.open(destFileName.c_str(), ios_base::out);
	string s;
	while (getline(file1, s)){
		v.push_back(s);
	}
	while (v.empty() == 0){
		file2 << v.back() << endl;
		v.pop_back();
	}
	file1.close();
	file2.close();
	cout << "reverse file success";
	return 0;
}

int main(){
	copyReverse("in.txt", "out.txt");
}
